package com.link2room.rodimus.nmsrunner;

import com.aliyun.mns.model.Message;
import com.link2room.common.mns.Worker;
import com.link2room.common.util.JacksonUtil;
import com.link2room.rodimus.dto.param.api.CouponPresentResetParamDto;
import com.link2room.rodimus.facade.ICouponFacadeService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by LN on 2017/7/31.11:56
 */
@Component("couponPresentResetWorker")
public class CouponPresentResetWorker implements Worker {
    @Resource
    private ICouponFacadeService couponFacadeService;
    @Override
    public boolean exec(Message message) throws Exception {
        try {
            if(message.getDequeueCount()== 1){
                CouponPresentResetParamDto paramDto = JacksonUtil.jsonToBean(message.getMessageBody(),CouponPresentResetParamDto.class);
                couponFacadeService.presentCouponReset(paramDto);
            }
        }finally {
            return true;
        }

    }
}
